package com.paperlessmedical.action;

import java.util.LinkedHashMap;


import javax.annotation.Resource;
import org.springframework.stereotype.Controller;

import com.opensymphony.xwork2.ActionSupport;
import com.paperlessmedical.bean.PageView;
import com.paperlessmedical.bean.QueryResult;
import com.paperlessmedical.entity.Doctor;
import com.paperlessmedical.service.DoctorService;

@Controller @SuppressWarnings("serial")
public class DoctorAction extends ActionSupport{
	 @Resource(name="doctorServiceImpl")
	 private DoctorService doctorService ;
 
	 private PageView<Doctor> pageView;
	 private int pageID;
	 private String name;
	 private String query; 
	 private QueryResult<Doctor> qr;
     
     public String doctorList(){
    	 LinkedHashMap<String, String> orderby = new LinkedHashMap<String, String>();
 		 orderby.put("doctor_Id", "desc");
    	 pageView=new PageView<Doctor>(12,pageID);
 		 int firstindex= (pageView.getCurrentpage()-1)*pageView.getMaxresult();
 		 qr=doctorService.getScrollDate_Hql(Doctor.class, firstindex, pageView.getMaxresult(),orderby);
 		 pageView.setQueryResult(qr); 
 		 return "doctorlist";
     }
     
	public PageView<Doctor> getPageView() {
		return pageView;
	}

	public void setPageView(PageView<Doctor> pageView) {
		this.pageView = pageView;
	}

	public int getPageID() {
		return pageID;
	}

	public void setPageID(int pageID) {
		this.pageID = pageID;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public String getQuery() {
		return query;
	}

	public void setQuery(String query) {
		this.query = query;
	}
}
